﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Xml;

namespace Summerset.Isbndb.Authors
{
    /// <summary>
    /// Represents additional details about an AuthorsResponseElement.
    /// </summary>
    public sealed class AuthorElementDetail : ResponseElementChildBase
    {
        #region Constructor + Overridden Properties
        /* Element Example:
            //<Details first_name="Anthony" last_name="Atkinson" dates="" has_books="1" />
         */

        /// <summary>
        /// Initializes a new instance of the <see cref="AuthorElementDetail"/> class.
        /// </summary>
        /// <param name="element">The xml element that contains the underlying data for this instance.</param>
        public AuthorElementDetail(XmlElement element)
            : base(element) { }

        /// <summary>
        /// Gets the expected name of the element that must be passed to this class' constructor.
        /// </summary>
        protected override string ExpectedElementName
        {
            get { return "Details"; }
        }

        #endregion
        #region Properties

        /// <summary>
        /// Gets the author's first name.
        /// </summary>
        public string FirstName
        {
            get { return _element.Attributes["first_name"].Value; }
        }

        /// <summary>
        /// Gets the author's last name.
        /// </summary>
        public string LastName
        {
            get { return _element.Attributes["last_name"].Value; }
        }

        /// <summary>
        /// Gets the dates?  This is not documented in the isbndb.com api.
        /// This is set to EditorBrowsable because I'm unaware of what this actually returns. 
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never)]
        public string Dates
        {
            get { return _element.Attributes["dates"].Value; }
        }

        /// <summary>
        /// Gets a value that indicates whether this author has books.  This is not documented in the isbndb.com api.
        /// This is set to EditorBrowsable because I'm unaware of what this actually returns.
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never)]
        public string HasBooks
        {
            get { return _element.Attributes["has_books"].Value; }
        }

        #endregion
    }
}
